//
//  SetUpTheVC.m
//  Logistics
//
//  Created by enzhoukeji on 2018/8/9.
//  Copyright © 2018年 puyue.com. All rights reserved.
//

#import "SetUpTheVC.h"
#import "WFeedbackVC.h"
@interface SetUpTheVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *setUpTV;
@property (nonatomic,strong)UILabel * cacheLab;
@property (nonatomic, strong) NSArray * OneTitleArray;

@end

@implementation SetUpTheVC
-(UITableView *)setUpTV{
    if (!_setUpTV) {
        _setUpTV=[[UITableView alloc]initWithFrame:CGRectMake(0, kMainTopHeight, kMainScreen_width, kMainScreen_height-kMainTopHeight) style:UITableViewStylePlain];;
        _setUpTV.delegate=self;
        _setUpTV.dataSource=self;
         _setUpTV.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
        
    }
    return _setUpTV;
}
-(NSArray *)OneTitleArray {
    if (!_OneTitleArray) {
        _OneTitleArray = [NSArray arrayWithObjects:@"更换手机号",@"意见反馈",@"关于我们",@"清除缓存",@"当前版本",nil];
    }
    return _OneTitleArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
     self.navTitle = @"设置";
    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [self.view addSubview:self.setUpTV];
    // Do any additional setup after loading the view.
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    if (!cell) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;//cell不被选中
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.text = self.OneTitleArray[indexPath.row];
    if (indexPath.row == 4) {
        self.cacheLab = [UILabel labelWithSize:[UIFont systemFontOfSize:13] withColor:[UIColor colorWithRed:0.76 green:0.76 blue:0.76 alpha:1.00] withText:nil];
        self.cacheLab.text = @"V1.01";
        [cell addSubview:self.cacheLab];
        [self.cacheLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(@(GTFixHeightFlaot(10)));
            make.right.equalTo(@(GTFixWidthFlaot(-20)));
            make.bottom.equalTo(cell.mas_bottom).offset(GTFixHeightFlaot(-10));
            make.width.equalTo(@(GTFixWidthFlaot(60)));
        }];
    }
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return GTFixHeightFlaot(45);
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return GTFixHeightFlaot(5);
}
-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView * footView = [UIView new];
    UILabel * label = [UILabel labelWithSize:nil withColor:nil withText:nil];
    label.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1];
    UIButton * button = [UIButton buttonWithTitle:@"退出账号" withImageName:nil withBGColor:[UIColor whiteColor] Withlayer:NO];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [footView addSubview:label];
    [footView addSubview:button];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(kMainScreen_width);
        make.height.mas_equalTo(GTFixHeightFlaot(5));
    }];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(label.mas_bottom).offset(0);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(kMainScreen_width);
        make.height.mas_equalTo(GTFixHeightFlaot(40));
    }];
    return footView;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView * headerView = [UIView new];
    headerView.backgroundColor = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1];
    return headerView;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section  {
    return GTFixHeightFlaot(45);
}
-(void)viewDidLayoutSubviews {
    
    if ([self.setUpTV respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.setUpTV setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([self.setUpTV respondsToSelector:@selector(setLayoutMargins:)])  {
        [self.setUpTV setLayoutMargins:UIEdgeInsetsZero];
    }
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPat{
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 1) {
        WFeedbackVC * vc = [WFeedbackVC new];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
